//
//  XYImageProcessController.m
//  XYSfxyxuSwift
//
//  Created by 许洋 on 2018/3/10.
//  Copyright © 2018年 许洋. All rights reserved.
//

#import "XYImageProcessController.h"
#import "XYImageUtils.h"
@interface XYImageProcessController ()
@property (nonatomic,strong) UIImageView *imageView;

@end

@implementation XYImageProcessController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(50, 50, self.view.bounds.size.width-100, 200)];
    imageView.clipsToBounds = YES;
    imageView.contentMode = UIViewContentModeScaleAspectFill;
    [self.view addSubview:imageView];
    _imageView = imageView;
    imageView.image = [UIImage imageNamed:@"热巴"];
    UIButton *restoreBtn = [[UIButton alloc]init];
    [restoreBtn addTarget:self action:@selector(restoreAction:) forControlEvents:UIControlEventTouchUpInside];
    [restoreBtn setTitle:@"还原" forState:UIControlStateNormal];
    UIButton *processBtn = [[UIButton alloc]init];
    [processBtn addTarget:self action:@selector(processAction:) forControlEvents:UIControlEventTouchUpInside];
    [processBtn setTitle:@"美白" forState:UIControlStateNormal];

    [self.view addSubview:restoreBtn];
    [self.view addSubview:processBtn];
    [restoreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo (self.view).offset(20);
        make.right.equalTo (processBtn.mas_left).offset(40);
        if (@available(iOS 11.0, *)) {
            make.bottom.equalTo (self.view.mas_safeAreaLayoutGuide);
        } else {
            make.bottom.equalTo (self.view);
        }
        make.height.mas_equalTo(50);
        make.width.equalTo(processBtn.mas_width);
    }];
    [processBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo (self.view).offset(-20);
        make.left.equalTo (restoreBtn).offset(-40);
        make.bottom.equalTo (self.view.mas_safeAreaLayoutGuide);
        make.height.mas_equalTo(50);

       
    }];

    // Do any additional setup after loading the view.
}
-(void)restoreAction:(id)sender{
    _imageView.image = [XYImageUtils image:_imageView.image];
}
-(void)processAction:(id)sender{
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
